Kanzi 3.9.10
KanziViewAdapter Class Reference

KanziViewAdapter allows embedding Kanzi UI content into an Android view. More...

Public Member Functions

 KanziViewAdapter (Context context, String name)
 Constructor to use when operating without a view.
 
 KanziViewAdapter (View view, AttributeSet attrs)
 Constructor to use when inflating a view from XML.
 
 KanziViewAdapter (View view, String name)
 Constructor to use when attaching to a view.
 
void addListener (KanziViewListener listener)
 Adds a view state change listener.
 
Domain getDomain ()
 Gets the Domain associated with this view.
 
String getName ()
 Gets the name of the underlying native view node.
 
Node2D getRoot ()
 Returns the root node of the underlying native view's node tree.
 
KanziRuntime getRuntime ()
 Gets the KanziRuntime associated with this view.
 
void handleActivityStarted ()
 Notifies the adapter that the Activity has started.
 
void handleActivityStopped ()
 Notifies the adapter that the Activity has stopped.
 
void handleAttachedToWindow ()
 Notifies the adapter of the attachment of the associated view to a window.
 
void handleDetachedFromWindow ()
 Notifies the adapter of the detachment of the associated view from its window.
 
void handleFocusChange (boolean hasFocus)
 Handles focus change.
 
boolean handleGenericMotionEvent (MotionEvent event)
 Handles the specified rotary controller knob rotation event if the view is in direct manipulation mode.
 
boolean handleKeyEvent (final int keyCode, KeyEvent event)
 Handles key events.
 
void handleOrientationChange (int orientation)
 Applies device orientation changes to the Kanzi contents of associated view.
 
void handleSurfaceChanged (Surface surface, int width, int height)
 Notifies the adapter of any changes in the dimensions of the surface of the associated view.
 
void handleSurfaceCreated (Surface surface)
 Notifies the adapter of availability of surface of the associated view.
 
void handleSurfaceDestroyed ()
 Notifies the adapter of the destruction of the surface of the associated view.
 
boolean handleTouchEvent (final MotionEvent event)
 Handles touch events.
 
void handleVisibilityChange (boolean isVisible)
 Notifies the adapter that the visibility has changed.
 
void removeListener (KanziViewListener listener)
 Removes a view state change listener.
 
void setClearColor (ColorRGBA color)
 Configures the clear color that is used when rendering of the surface of the view.
 
void setKzbPathList (String[] kzbPaths)
 Configures the list of kzb files that are loaded when the view is attached.
 
void setName (String name)
 Sets the name for the underlying native view node.
 
void setRoot (Node2D node)
 Sets the root node of the underlying native view's node tree, used to manually set content to the view.
 
void setRotaryHandlingEnabled (boolean enable)
 Sets whether the adapter processes rotary controller events.
 
void setStartupPrefabUrl (String url)
 Configures the startup prefab that is automatically loaded during initialization.
 

Detailed Description

KanziViewAdapter allows embedding Kanzi UI content into an Android view.

Alternatively, you can use one of the Kanzi view classes: KanziSurfaceView and KanziTextureView.

Constructor & Destructor Documentation

◆ KanziViewAdapter() [1/3]

KanziViewAdapter ( View view,
AttributeSet attrs )

Constructor to use when inflating a view from XML.

Parameters
viewReference to the view being adapted.
attrsAttributes received when inflating the view from XML.

◆ KanziViewAdapter() [2/3]

KanziViewAdapter ( View view,
String name )

Constructor to use when attaching to a view.

Parameters
viewReference to the view being adapted.
nameA name for the underlying native view node.

◆ KanziViewAdapter() [3/3]

KanziViewAdapter ( Context context,
String name )

Constructor to use when operating without a view.

Parameters
contextReference to the application context.
nameA name for the underlying native view node.

Member Function Documentation

◆ addListener()

void addListener ( KanziViewListener listener)

Adds a view state change listener.

Parameters
listenerAn instance of KanziViewListener.

◆ getDomain()

Domain getDomain ( )

Gets the Domain associated with this view.

Returns
Domain associated with this view.

◆ getName()

String getName ( )

Gets the name of the underlying native view node.

Returns
Name of the underlying native view node.

◆ getRoot()

Node2D getRoot ( )

Returns the root node of the underlying native view's node tree.

Returns
Reference to the root node. If called before StartupPrefab has finished loading, returns Null.

◆ getRuntime()

KanziRuntime getRuntime ( )

Gets the KanziRuntime associated with this view.

Returns
KanziRuntime associated with this view.

◆ handleActivityStarted()

void handleActivityStarted ( )

Notifies the adapter that the Activity has started.

Activates the view node.

◆ handleActivityStopped()

void handleActivityStopped ( )

Notifies the adapter that the Activity has stopped.

Deactivates the view node.

◆ handleAttachedToWindow()

void handleAttachedToWindow ( )

Notifies the adapter of the attachment of the associated view to a window.

Initializes runtime if this is the first Kanzi based view to be attached in this application. Initializes the underlying view node and initiates asynchronous loading of its start-up prefab if configured.

◆ handleDetachedFromWindow()

void handleDetachedFromWindow ( )

Notifies the adapter of the detachment of the associated view from its window.

Releases the underlying view node.

◆ handleFocusChange()

void handleFocusChange ( boolean hasFocus)

Handles focus change.

Call this to inform Kanzi of changes in the focus of a Kanzi-based-view. Kanzi view types com.rightware.kanzi.KanziSurfaceView and com.rightware.kanzi.KanziTextureView do this by default, so you don't have to.

Parameters
hasFocusTrue if the View has focus; false otherwise.

◆ handleGenericMotionEvent()

boolean handleGenericMotionEvent ( MotionEvent event)

Handles the specified rotary controller knob rotation event if the view is in direct manipulation mode.

To handle rotary controller knob rotation events and translate them to focus navigation events, forward generic motion events to this function. Use this function to process rotary controller events of an arbitrary view that uses com.rightware.kanzi.KanziViewAdapter. Kanzi views com.rightware.kanzi.KanziSurfaceView and com.rightware.kanzi.KanziTextureView forward all the generic motion events to this function, so you do not have to.

Parameters
eventThe MotionEvent object that defines the knob rotation action.
Returns
True, if the event was handled, false otherwise.

◆ handleKeyEvent()

boolean handleKeyEvent ( final int keyCode,
KeyEvent event )

Handles key events.

You can forward key events received by Kanzi-based-view to this function, if you want Kanzi to handle them. Kanzi view types com.rightware.kanzi.KanziSurfaceView and com.rightware.kanzi.KanziTextureView do this by default, so you don't have to.

Parameters
keyCodea key code that represents the button pressed, from android.view.KeyEvent.
eventthe KeyEvent object that defines the button action.
Returns
True if the event was handled, false otherwise.

◆ handleOrientationChange()

void handleOrientationChange ( int orientation)

Applies device orientation changes to the Kanzi contents of associated view.

Parameters
orientationThe orientation qualifier from onOrientationChanged().

◆ handleSurfaceChanged()

void handleSurfaceChanged ( Surface surface,
int width,
int height )

Notifies the adapter of any changes in the dimensions of the surface of the associated view.

Parameters
surfaceThe new surface
widthThe new width of the surface.
heightThe new height of the surface.

◆ handleSurfaceCreated()

void handleSurfaceCreated ( Surface surface)

Notifies the adapter of availability of surface of the associated view.

Sets the surface as the target of the graphics context of the underlying view node. Activates the view node.

Parameters
surfaceThe surface

◆ handleSurfaceDestroyed()

void handleSurfaceDestroyed ( )

Notifies the adapter of the destruction of the surface of the associated view.

Detaches the graphics context of the underlying view node from this surface. Deactivates the view node.

◆ handleTouchEvent()

boolean handleTouchEvent ( final MotionEvent event)

Handles touch events.

You can forward touch events received by Kanzi-based-view to this function, if you want Kanzi to handle them. Kanzi view types com.rightware.kanzi.KanziSurfaceView and com.rightware.kanzi.KanziTextureView do this by default, so you don't have to.

Parameters
eventThe touch event.
Returns
True if the event was handled, false otherwise.

◆ handleVisibilityChange()

void handleVisibilityChange ( boolean isVisible)

Notifies the adapter that the visibility has changed.

Use this method only when your application is in a view-less context, such as a WallpaperEngine.

Toggles the activation of the Kanzi View.

Parameters
isVisibleWhether the surface is visible and must be rendered.

◆ removeListener()

void removeListener ( KanziViewListener listener)

Removes a view state change listener.

Parameters
listenerThe instance of KanziViewListener to remove.

◆ setClearColor()

void setClearColor ( ColorRGBA color)

Configures the clear color that is used when rendering of the surface of the view.

Parameters
colorColor used to clear the surface of the view. Use null to skip clearing.

◆ setKzbPathList()

void setKzbPathList ( String[] kzbPaths)

Configures the list of kzb files that are loaded when the view is attached.

Parameters
kzbPathsArray of kzb paths to load.

◆ setName()

void setName ( String name)

Sets the name for the underlying native view node.

Parameters
nameNew name for native view node.

◆ setRoot()

void setRoot ( Node2D node)

Sets the root node of the underlying native view's node tree, used to manually set content to the view.

Parameters
nodeReference to a node.

◆ setRotaryHandlingEnabled()

void setRotaryHandlingEnabled ( boolean enable)

Sets whether the adapter processes rotary controller events.

Parameters
enableIf true, the adapter processes rotary controller input, otherwise related input events are ignored.

◆ setStartupPrefabUrl()

void setStartupPrefabUrl ( String url)

Configures the startup prefab that is automatically loaded during initialization.

Parameters
urlUrl of the prefab template to load.